<?php

namespace App\Http\Requests;

use App\Rules\IdNumber;
use App\Rules\Phone;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class SupplierRegister extends FormRequest
{
    /**
     * @var bool
     */
    protected $stopOnFirstFailure = true;

    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules(): array
    {
        return [
            'phone'                     => ['required', new Phone, Rule::unique('App\Models\Admin\Supplier')],
            'login_password'            => 'required',
            'actual_name'               => 'required',
            'id_number'                 => ['required', new IdNumber],
            'company_name'              => 'required',
            'business_license_number'   => 'required',
//            'domain'                    => 'required|url',
        ];
    }

    /**
     * @return array
     */
    public function messages(): array
    {
        return [
            'phone.required'                        => '请输入手机号',
            'phone.unique'                          => '当前手机号已注册',
            'login_password.required'               => '请输入登录密码',
            'actual_name.required'                  => '请填写真实姓名',
            'id_number.required'                    => '请填写身份证号码',
            'company_name.required'                 => '请填写公司名称',
            'business_license_number.required'      => '请填写营业执照号码',
//            'domain.required'                       => '请填写您的域名地址',
//            'domain.url'                            => '请填写正确的域名地址',
        ];
    }
}
